﻿<%@ Page Language="C#" AutoEventWireup="true"  Title="" %>
<%@ import namespace="System.Web.UI" %>
<%@ import namespace="System.Web.UI.WebControls" %>
    <link rel="stylesheet" href="<%=Page.ResolveClientUrl("~/")%>Manager/css/site_css.css"  type="text/css">
    <link rel="stylesheet" href='<%=Page.ResolveClientUrl("~/")%>Manager/css/table/<%=wlFrame.Common.TableSink%>/Css.css' type="text/css">
<script runat=server language="C#">
wlData.TableConfig db = new wlData.TableConfig();
wlFrame.FileUpLoadCommon fc = new wlFrame.FileUpLoadCommon();//默认构造,放在PUBLIC,且按日期生成子目录
string err="";
      private bool UpPhoto()
        {
        //fc.PromteExt="txt,jpg,png,gif,bmp,swf,doc,xls,pdf";
        //fc.MaxSize=5096;//kb
         if(fc.SaveFile(U_PhotoUrl.PostedFile,false,false))
         {
             string filename = "/public/" + fc.newFileName.Substring(0, 8) + "/" + fc.newFileName;
             err = string.Format("insert into m_fujian(title,path,tableid,filesize,fileext)values('{0}','{1}','{2}','{3}','{4}')", U_PhotoUrl.FileName, filename, Request["tableid"], fc.fileSize, fc.fileType);
          //Response.Write(err);
           db.runSql(err);
          err="";
         }
         else err=fc.errorMsg;
         if(err=="") return true; else return false;
         
        }
     private bool del()
     { string filename=db.runASql("select path from m_fujian where id='"+Request["fujianid"]+"'");
       if(filename!="")
           if(db.runSql("delete from m_fujian where id='"+Request["fujianid"]+"'"))
           {  wlFrame.FileUpLoadCommon.DeleteFile(filename);
           
              db.outScript("alert('成功删除附件！');location.href='?tableid="+Request["tableid"]+"';");
              return true;

              }
       return false;
     }   
</script>
<%
     if(Request["CMD"]=="delFujian") del();
    if (U_PhotoUrl.FileName != "")  UpPhoto();
%>
<body margin="0">
<table width="100%">
<form runat=server >   <tr id="TopTr">
                    <td class="table_none" style="width:80%" align=right>
                       <asp:FileUpload ID="U_PhotoUrl" runat="server" contentEditable=false CssClass="text_input"  style="width:100%"  />
</td><td  class="table_none" style="width:10%" >                      
 <input type=submit value="上传">
 </td> <td  class="table_none" style="width:10%" nowrap>  
<%=err%></td></tr></form></table><table width="100%">
   <tr id="TopTr">
                    
                    <td  class="table_none" align=left>
      <%  string tableid=Request["tableid"];
           db.TableName="m_fujian";
    	   db.FieldList="tableid,title,path,id";
           db.WhereStr="tableid='"+tableid+"'"; 
           db.OrderStr = "id";
           db.PageSize = 0;
           db.PageStr="0";
           System.Data.DataTable dt =db.pageTable();
          // Response.Write(db.sql);
           if(dt!=null) for(int i=0;i<dt.Rows.Count;i++)
          {%>
          
          <a href='<%=dt.Rows[i][2] %>'" target="_blank"><%=dt.Rows[i][1] %></a>&nbsp;
          <img src="<%=Page.ResolveUrl("~/") %>Manager/images/listEdit/wrong.gif" style="border: none" onclick="if( confirm('真的要删除么？')) location.href='?CMD=delFujian&tableid=<%=tableid%>&fujianid=<% =dt.Rows[i][3] %>'; " />       
        
      <%}%> 
</td></tr>
</table>
</body>

<!-- window.top.adaptIFrameHeight(parseInt(window.location.hash.substring(1),10)); -->